package com.lrs.java.j2se_advanced.regexp;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class EmailSpider {
	public static int num = 0;
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new FileReader("D:\\share\\ss.html"));
			String str = "";
			while((str=br.readLine()) != null) {
				parse(str);
			}
			System.out.println(EmailSpider.num);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private static void parse(String str) {
		Pattern p = Pattern.compile("[\\w[.-]]+@[\\w]+\\.[\\w[.-]]+" );
		Matcher m = p.matcher(str);
		while(m.find()) {
			num++;
			System.out.println(m.group());
		}
		
	}
}
